package com.yael.tables;

import java.io.Serializable;
import java.util.Date;

import javax.jdo.PersistenceManager;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.yael.utils.CacheManagerService;
import com.yael.utils.Datastore;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class NP_NETWORK_IDENTITY implements Serializable {

	@Persistent
	private static final long serialVersionUID = 1L;

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long networkID;
	
	@Persistent
	private String networkName;
	
	@Persistent
	private String networkIdetifier;
	
	@Persistent
	private String networkType;
	
	@Persistent
	private Long businessID;
	
	@Persistent
	private int selfIdetityFlag;
	
	@Persistent
	private int enableFlag;
	
	@Persistent
	private int rangeUnit;
	
	@Persistent
	private int kosherFlag;
	
	@Persistent
	private String aliasNetworkID;
	
	@Persistent
	private String aliasNetworkLrn;
	
	@Persistent
	private String createdBy;
	
	@Persistent
	private Date creatDate;
	
	@Persistent
	private String lastUpdateBy;
	
	@Persistent
	private Date lastUpdateDate;

	public Long getNetworkID() {
		return networkID;
	}

	public void setNetworkID(Long networkID) {
		this.networkID = networkID;
	}

	public String getNetworkName() {
		return networkName;
	}

	public void setNetworkName(String networkName) {
		this.networkName = networkName;
	}

	public String getNetworkIdetifier() {
		return networkIdetifier;
	}

	public void setNetworkIdetifier(String networkIdetifier) {
		this.networkIdetifier = networkIdetifier;
	}

	public String getNetworkType() {
		return networkType;
	}

	public void setNetworkType(String networkType) {
		this.networkType = networkType;
	}

	public Long getBusinessID() {
		return businessID;
	}

	public void setBusinessID(Long businessID) {
		this.businessID = businessID;
	}

	public int getSelfIdetityFlag() {
		return selfIdetityFlag;
	}

	public void setSelfIdetityFlag(int selfIdetityFlag) {
		this.selfIdetityFlag = selfIdetityFlag;
	}

	public int getEnableFlag() {
		return enableFlag;
	}

	public void setEnableFlag(int enableFlag) {
		this.enableFlag = enableFlag;
	}

	public int getRangeUnit() {
		return rangeUnit;
	}

	public void setRangeUnit(int rangeUnit) {
		this.rangeUnit = rangeUnit;
	}

	public int getKosherFlag() {
		return kosherFlag;
	}

	public void setKosherFlag(int kosherFlag) {
		this.kosherFlag = kosherFlag;
	}

	public String getAliasNetworkID() {
		return aliasNetworkID;
	}

	public void setAliasNetworkID(String aliasNetworkID) {
		this.aliasNetworkID = aliasNetworkID;
	}

	public String getAliasNetworkLrn() {
		return aliasNetworkLrn;
	}

	public void setAliasNetworkLrn(String aliasNetworkLrn) {
		this.aliasNetworkLrn = aliasNetworkLrn;
	}

	public String getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}

	public Date getCreatDate() {
		return creatDate;
	}

	public void setCreatDate(Date creatDate) {
		this.creatDate = creatDate;
	}

	public String getLastUpdateBy() {
		return lastUpdateBy;
	}

	public void setLastUpdateBy(String lastUpdateBy) {
		this.lastUpdateBy = lastUpdateBy;
	}

	public Date getLastUpdateDate() {
		return lastUpdateDate;
	}

	public void setLastUpdateDate(Date lastUpdateDate) {
		this.lastUpdateDate = lastUpdateDate;
	}
	
	 public NP_NETWORK_IDENTITY store(PersistenceManager pm, CacheManagerService cm) {
		 NP_NETWORK_IDENTITY network = null;
	        try {
	        	network = pm.makePersistent(this);
	        	this.networkID = network.getNetworkID();
	        	cm.setValue(Long.toString(this.networkID), this);
	        } finally {
	            pm.close();
	        }
	        return this;
	 }
	 
	 public static NP_NETWORK_IDENTITY retriveByID(PersistenceManager pm, CacheManagerService cs, String messageID){
		 Object object = null;
		 object = cs.getValue(messageID);
		 if(object!=null) {
			 object = Datastore.retriveByID(pm, NP_NETWORK_IDENTITY.class, Long.parseLong(messageID));
			 cs.setValue(messageID, object);
		 }
		 if(object!=null) return (NP_NETWORK_IDENTITY) object;
		 return null;
	 }
}

